/*
 * This file is a part of the RMI Plugin for Eclipse tutorials.
 * Copyright (C) 2002-7 Genady Beryozkin
 */
package oldVersion.hifi;

/**
 *@author Adam
 */

import hifiSpeakers.Player;

import java.net.InetAddress;
import java.rmi.RMISecurityManager;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;

import server.RMIServer;



/**
 * This is a simple print client.
 * 
 * @author Genady Beryozkin, rmi-info@genady.net
 */
public class RMIClient {

	public Hifi parent;
	public Player player;
	public RMIClient(Hifi s){
		parent =s;
	}
	
	public void play(){
		
	}

	public void begin(String location) {
		System.setSecurityManager(new RMISecurityManager());
		String IP = "";
		try{
			InetAddress thisIp =InetAddress.getLocalHost();
			IP = thisIp.getHostAddress();
		} catch(Exception e){
			e.printStackTrace();
		}
		try {
			Registry registry = LocateRegistry.getRegistry(location);
			RMIServer RMIServer = (RMIServer)registry.lookup("RMIServer");
			RMIServer.registerHifi(IP);
			while(true){
				String s = RMIServer.HifiWhatToPlay();
				
				//
				
				player.init(ip, port);	//data sink ip and port is to be given here.
				
				
			}
			
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	public void playTrack(String url){
		
		
		
		
	}
	
}
